﻿using RepositoryDefinition;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RepositoryImplementation
{
    public class CategoryRepository:ICategoryRepository
    {
        public List<ForumDomainModels.Category> GetCategoriesBySection(ForumDomainModels.Section section)
        {
            try
            {
                ForumDAL.CategoryDAL categoryContext = new ForumDAL.CategoryDAL();
                List<ForumDomainModels.Category> categories = categoryContext.GetCategoriesBySection(section);
                return categories;
            }
            catch (ForumDAL.CustomExceptions.NoRowsRetrieved e)
            {
                return null;
            }
        }


        public ForumDomainModels.Category GetCategoryById(ForumDomainModels.Category category)
        {
            try
            {
                ForumDAL.CategoryDAL categoryContext = new ForumDAL.CategoryDAL();
                ForumDomainModels.Category retrievedCategory = categoryContext.GetCategoryById(category);
                return retrievedCategory;
            }
            catch (ForumDAL.CustomExceptions.NoRowsRetrieved e)
            {
                return null;
            }
            
        }
    }
}
